package com.seek.educms.controller;


import com.seek.commonutils.ResponseResult;
import com.seek.educms.entity.CrmBanner;
import com.seek.educms.service.CrmBannerService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 首页banner表 前台前端控制器
 * </p>
 *
 * @author wml
 * @since 2022-02-10
 */
@RestController
@RequestMapping("/educms/banner")
public class CrmBannerMainSiteController {

    @Autowired
    private CrmBannerService crmBannerService;

    // 查询所有 banner
    @ApiOperation(value = "获取首页 banner")
    @GetMapping
    public ResponseResult getAllBanner() {
        List<CrmBanner> list = crmBannerService.getAllBanner();
        return ResponseResult.ok().data("bannerList", list);
    }

    // 根据 isShow 字段，查询 banner
    @ApiOperation(value = "根据 show 字段，获取首页 banner")
    @GetMapping("getListByIsShow")
    public ResponseResult getListByIsShow() {
        List<CrmBanner> list = crmBannerService.getAllBannerByIsShow();
        return ResponseResult.ok().data("bannerList", list);
    }

}

